home *** CD-ROM | disk | FTP | other *** search
- ;; tobase(n,base): convert n (base 10) to base. eg (tobase 10 16) => A
- ;; C Durland Public Domain
-
- (include mod.mut)
- (defun
- tobase (int n base) HIDDEN
- {
- (if (< n base) (extract-elements "0123456789ABCDEF" n 1)
- (concat
- (tobase (/ n base) base) ; tobase n/base base
- (tobase (mod n base) base) ; tobase (n mod base) base
- )
- )
- }
- )
- ;(msg (tobase (convert-to NUMBER (ask "n = "))
- ; (convert-to NUMBER (ask "base = "))))
-